﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Brain;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Brain.Rendering;

namespace Demos
{
    public class LittleCityOfBoxesScreen : DemoScreen
    {
        public LittleCityOfBoxesScreen()
        {
            Viewport viewport = Engine.Instance.GraphicsDevice.Viewport;

            InputFreeCamera3D Camera = new InputFreeCamera3D(this);
            Camera.AspectRatio = viewport.AspectRatio;
            Camera.FarPlane = 1000f;
            Camera.DegreesRotation = new Vector3(-52, -24, 0);
            Camera.Position = new Vector3(-43, 59, 165);
            Camera.InitialPosition = Camera.Position;
            Camera.InitialRotationRadians = Camera.RotationRadians;
            Engine.Instance.CameraManager.Camera3D = Camera;
            
            float Size = 150;

            float lineSize = Size / 15f;

            // Make the City
            float ModSize = Size * 1.2f;
            WorldObject ground = new WorldObject("Game\\Models\\model_box");
            ground.Position = new Vector3(0, 0, 0);
            ground.Scale = new Vector3(10000, 1, 10000);
            ground.Update();
            ground.Draw();
            ground.Rendering = WorldObjectRendering.Rendered;

            // 15 lines x 15 lines
            int lines = 15;
            // We make 15 by 15 lines by using the Array System
            Vector3[] vec =
                ArrayUtil.MakeArray(new Vector3(0, 1, 0), lines, new Vector3(lineSize, 0, 0), lines, new Vector3(0, 0, lineSize), 0, Vector3.Zero);

            for (int i = 0; i < vec.Length; i++)
            {
                Vector3 v = vec[i];
                WorldObject block = new WorldObject("Game\\Models\\model_box");
                block.Position = v;
                block.Scale = new Vector3(lineSize / 2f, RandomUtil.Next(2, 25, 100), lineSize / 2f);
                block.Update();
                block.Draw();
                block.Rendering = WorldObjectRendering.Rendered;
            }
        }


        public override void Draw()
        {
            base.Draw();
        }
    }
}
